<%@ page language="java" import="java.util.*"
	contentType="text/html; charset=utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>任务调度 | 日志</title>
<!-- Tell the browser to be responsive to screen width -->
<meta
	content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
	name="viewport">
<!-- Bootstrap 3.3.5 -->
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
<!-- Font Awesome -->
<link rel="stylesheet"
	href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
<!-- Ionicons -->
<link rel="stylesheet"
	href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
<!-- DataTables -->
<link rel="stylesheet"
	href="plugins/datatables/dataTables.bootstrap.css">
<!-- datepicker -->

<link rel="stylesheet"
	href="plugins/datepicker/datepicker3.css">


<!-- Theme style -->
<link rel="stylesheet" href="dist/css/AdminLTE.min.css">
<!-- AdminLTE Skins. Choose a skin from the css/skins
         folder instead of downloading all of them to reduce the load. -->
<link rel="stylesheet" href="dist/css/skins/_all-skins.min.css">

<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
        <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body class="hold-transition skin-blue sidebar-mini">
	<div class="wrapper">

		<header class="main-header">
			<jsp:include page="header.jsp"></jsp:include>
		</header>
		<!-- Left side column. contains the logo and sidebar -->
		<aside class="main-sidebar">
			<!-- sidebar: style can be found in sidebar.less -->
			<section class="sidebar">
				<jsp:include page="left-menu.jsp" />
			</section>
			<!-- /.sidebar -->
		</aside>

		<!-- Content Wrapper. Contains page content -->
		<div class="content-wrapper">
			<!-- Content Header (Page header) -->
			
			<!-- Main content -->
			<section class="content">
				<div class="row">
					<div class="col-xs-12">
						<div class="box">

							<div class="col-xs-12">
								<form class="form-horizontal" role="form">
									<fieldset>
										<legend>自动任务日志查询</legend>
										<div class="form-group">
											<label class="col-sm-1 control-label" for="begin">开始日期</label>
											<div class="col-sm-2">
												<input class="form-control" id="begin" type="text"
													placeholder="" />
											</div>
											<label class="col-sm-1 control-label" for="end">结束日期</label>
											<div class="col-sm-2">
												<input class="form-control" id="end" type="text"
													placeholder="" />
											</div>
											<label class="col-sm-1 control-label" for="jobName">任务URL</label>
											<div class="col-sm-2">
												<input class="form-control" id="jobName" type="text"
													placeholder="" />
											</div>
											<div class="col-sm-1">
												<button type='button' class='btn btn-success btn-sm' onclick="uf_searchlog();">查询日志记录</button>
											</div>
										</div>
										
									</fieldset>
								</form>
							</div>
							<!-- /.box-header -->
							<div class="box-body">
								<table id="joblist_table"
									class="table table-bordered table-hover">
									<thead>
										<tr>
											<th style="width: 5%" data-field="ss">日志ID</th>
											<th style="width: 35%" data-field="aa">任务URL</th>
											<th style="width: 10%" data-field="bb">执行时间</th>
											<th style="width: 42%" data-field="cc">错误信息</th>
											<th style="width: 8%" data-field="dd">执行结果</th>
										</tr>
									</thead>
									<tbody>
									</tbody>
									<!-- <tfoot>
										<tr>
											<th><button id="btn_addjob" type="button"
													class="btn btn-success btn-sm">新建任务</button></th>
										</tr>
									</tfoot> -->

								</table>
							</div>
							<!-- /.box-body -->
						</div>
						<!-- /.box -->
					</div>
					<!-- /.col -->
				</div>
				<!-- /.row -->
			</section>
			<!-- /.content -->
		</div>
		<!-- /.content-wrapper -->
		<!-- 
      <footer class="main-footer">
        <div class="pull-right hidden-xs">
          <b>Version</b> 2.3.0
        </div>
      </footer>
      -->
		<!-- Control Sidebar -->
		<!-- Add the sidebar's background. This div must be placed  immediately after the control sidebar -->
		<div class="control-sidebar-bg"></div>
	</div>
	<!-- ./wrapper -->

	<!-- jQuery 2.1.4 -->
	<script src="plugins/jQuery/jQuery-2.1.4.min.js"></script>
	<!-- Bootstrap 3.3.5 -->
	<script src="bootstrap/js/bootstrap.min.js"></script>
	<!-- DataTables -->
	<script src="plugins/datatables/jquery.dataTables.min.js"></script>
	<script src="plugins/datatables/dataTables.bootstrap.min.js"></script>
	<!-- SlimScroll -->
	<script src="plugins/slimScroll/jquery.slimscroll.min.js"></script>
	<!-- FastClick -->
	<script src="plugins/fastclick/fastclick.min.js"></script>

	<script src="bootstrap/js/bootbox.min.js"></script>
	<!-- datepicker -->
	<script src="plugins/datepicker/bootstrap-datepicker.js"></script>
	<script src="plugins/datepicker/locales/bootstrap-datepicker.zh-CN.js"></script>
	<!-- AdminLTE App -->
	<script src="dist/js/app.min.js"></script>
	<!-- AdminLTE for demo purposes -->
	<script src="dist/js/demo.js"></script>
	<!-- page script -->
	<script>
      var oTable = null;
      
      $(function () {
    	  oTable = $('#joblist_table').DataTable({
          "bAutoWidth":false,
          "bDestory":true,
          "bRetrieve":true,
          "bProcessing": true,
          "bServerSide": true,
          "bLengthChange":false,
          "bFilter":false,
          "bPaginate":true,
          "iDisplayLength":17,
          "pageLength":17,
          "bPaginationType": "simple_numbers",
          "sAjaxSource": "/task/searchlog",
	      "oLanguage": {
	          "sLengthMenu": "每页显示  _MENU_ 条记录",  
	          "sInfo": "从 _START_ 到 _END_ /共 _TOTAL_ 条数据",
	          "oPaginate": {
	              "sFirst": "首页",
	              "sPrevious": "前一页",
	              "sNext": "后一页",
	              "sLast": "尾页"
	              },
	          "sZeroRecords": "抱歉， 没有找到",
	          "sInfoEmpty": "没有数据"
	      }
        }); 
    	 
    	  $('#joblist_table tbody').on('click','tr',function(){
    		  
    	   	  var colIdx = oTable.row(this).index();
    	   	  //alert(oTable.row(colIdx).data()[0]);
    	   	  $.ajax({
     		     type: 'POST',
     		     url: '/task/geterrormsg?logid=' +  oTable.row(colIdx).data()[0],
     		     success: function(data){
     		    	bootbox.alert("错误信息：</br>"  + data);
     		     },
     		     error: function(data){}
     		     
     		});
    	   	  
    	   	  
    	 });
    	 $('#begin').datepicker({
    		    format: "yyyy-mm-dd 00:00:00",
    		    clearBtn: true,
    		    autoclose:true,
    		    language: "zh-CN"

    	  });
          
    	  $('#end').datepicker({
  		    format: "yyyy-mm-dd ",
  		    clearBtn: true,
  		    autoclose:true,
  		    language: "zh-CN"
  	      });
        
      });
      
      function uf_searchlog(){
    	  var iDisplayLength = 17;
    	  var jobName = $('#jobName').val();
    	  var end = $('#end').val();
    	  var begin = $('#begin').val();
    	  
    	  oTable.destroy();
    	  oTable = $('#joblist_table').DataTable({
              "bAutoWidth":false,
              "bDestory":true,
              "bRetrieve":true,
              "bProcessing": true,
              "bServerSide": true,
              "bLengthChange":false,
              "bFilter":false,
              "bPaginate":true,
              "iDisplayLength":17,
              "pageLength":17,
              "bPaginationType": "simple_numbers",
              "sAjaxSource": '/task/searchlog?jobName=' + jobName + '&begin=' + begin + '&end=' + end,
    	      "oLanguage": {
    	          "sLengthMenu": "每页显示  _MENU_ 条记录",  
    	          "sInfo": "从 _START_ 到 _END_ /共 _TOTAL_ 条数据",
    	          "oPaginate": {
    	              "sFirst": "首页",
    	              "sPrevious": "前一页",
    	              "sNext": "后一页",
    	              "sLast": "尾页"
    	              },
    	          "sZeroRecords": "抱歉， 没有找到",
    	          "sInfoEmpty": "没有数据"
    	      }
            }); 
    	  	
/*     	  $('#joblist_table tbody').on('click','tr',function(){
    		  alert('ddsd');
    	   	  var colIdx = oTable.row(this).index();
    	   	  $.ajax({
     		     type: 'POST',
     		     url: '/task/geterrormsg?logid=' +  oTable.row(colIdx).data()[0],
     		     success: function(data){
     		    	bootbox.alert("错误信息：</br>"  + data);
     		     },
     		     error: function(data){}
     		     
     		});  
    	 }); */
    	  
    	 /*  $.ajax({
  		     type: 'POST',
  		     url: '/task/searchlog?iDisplayLength=' + iDisplayLength + '&jobName=' + jobName + '&begin=' + begin + '&end=' + end,
  		     dataType: 'json',
  		     success: function(data){
  		    	
  		     },
  		     error: function(data){
  		    	bootbox.alert("错误信息：</br>"  + data);
  		     }
  		     
  		}); */
    	  
      }
      
      
    </script>
	<%@ page language="java" import="java.util.*"
		contentType="text/html; charset=utf-8"%>
	<div class="modal fade" id="myModal" tabindex="-1" role="dialog"
		aria-labelledby="myModalLabel" aria-hidden="true"></div>
	<!-- /.modal -->
</body>
</html>

